Skip to content

feat(ci): A 类设计还原度门禁脚本化 + Agent 协作基建收口文档(P0) - #41

Merged
babycoder-dev merged 2 commits into
mainfrom
chore/agent-infra-p0
Oct 7, 2026
Merged

babycoder-dev merged 2 commits into
mainfrom
chore/agent-infra-p0

Conversation

@babycoder-dev

Copy link
Copy Markdown
Owner

Summary

把 docs/development-workflow.md §7 的 A 类设计还原度门禁从"实现方自证"变成会红的检查——docs/agent-workflow.md 立项后的 P0 首项。

  • 新增 scripts/check-ui-fidelity.mjs:A1 零硬编码 hex、A2 零 emoji 当图标、A4 间距/圆角/阴影/字体只引 token。
    • 纯文件系统遍历、不 spawn 子进程(不调用 git/eslint),因此在受限沙箱、CI 与不同开发机上行为一致。
    • 扫描范围 apps/<app>/src、modules/<module>/web/src、packages/ui/src;tokens.css 是 hex 的唯一豁免。
  • 新增根脚本 pnpm fidelity,并接入 pnpm verify 与 CI(verify job 在 pnpm lint 之后跑)。
  • 新增 docs/agent-workflow.md(本仓「人 + 编码代理如何协作」的单一事实源:门禁清单、方言挂载、长任务 goal 纪律、skills / workflow 承载物、不搬清单、P0/P1/P2 落地顺序),并在 docs/doc-index.md 三处登记。

Verification

  • pnpm fidelity 现状通过:215 个文件,A1/A2/A4 无违规
  • 负向验证(逐条注入违规,全部抓到,注入已还原):
    • color: #ff0000; → [A1];padding: 13px; → [A4];emoji → [A2];三者同现时 exit 1
  • 仓库现状本就自律:components.css 的 padding 全部走 var(--sp-*);UI 源码里的 hex 仅存在于 tokens.css
  • 未新增任何依赖

Review Focus

  • A 类规则边界是否认可:A3(关键文案逐字一致)仍由 *.spec.tsx 断言承担;A4 只覆盖 padding|margin|gap|border-radius|box-shadow|font|font-size;letter-spacing / line-height / transform 与 TSX 内联样式不在扫描内——这些边界已写进文档,改规则需同步脚本与文档
  • tokens.css 作为 hex 唯一豁免是否合理
  • 不涉及 API / 权限 / 数据范围 / 数据库迁移 / 模块边界

备注

连带更正:我先前对 PR #36 的技术结论("@nx/enforce-module-boundaries 在 CI 里从未执行")经受控负向实验证明是错的——pnpm -r / nx run-many / pnpm --filter 三条路径都会抓出越界依赖并 exit 1。已在 #36 上发更正评论。教训已写进 docs/agent-workflow.md 第一原则:一行日志不是证据,会红的检查才是。

A1/A2/A4 were described as machine-checkable in docs/development-workflow.md §7 but had no script and no CI step, so in practice they were self-attestation. Adds scripts/check-ui-fidelity.mjs (pure filesystem walk, no subprocess, sandbox-safe), a pnpm fidelity script, the verify chain and a CI step, plus docs/agent-workflow.md as the single source of truth for agent collaboration infrastructure.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T06:25:43.065963Z c9cba44 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9cba44730

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/check-ui-fidelity.mjs Resolved
Codex (PR #41, P2) showed the rule only recognised px/rem/em, so font-size:3vw, padding:5% and margin:2ch bypassed the token-only rule. The unit list now covers all CSS lengths and percentages with the zero-value allowance kept, the declaration parser no longer assumes one declaration per line (the regression spec caught that), the rules moved to scripts/lib/ui-fidelity-rules.mjs and are covered by scripts/lib/ui-fidelity-rules.spec.mjs collected via vitest.
@babycoder-dev

Copy link
Copy Markdown
Owner Author

按 Codex 审查修复(44ce70c):

P2 · A4 只认 px|rem|em — 采纳。 原实现确实让 font-size: 3vw、padding: 5%、margin: 2ch 这类裸值绕过「只引 token」规则。

  • 单位表扩到全部 CSS 长度与百分比(px rem em ex ch cap ic lh rlh vw vh vi vb vmin vmax cm mm q in pc pt %),保留零值豁免(0 / 0px / 0%)。
  • 顺带让守卫自身有守卫(这正是这条 finding 的根因:规则没有回归测试):
    • 规则抽到 scripts/lib/ui-fidelity-rules.mjs,配 scripts/lib/ui-fidelity-rules.spec.mjs(27 条,覆盖各类单位的正/负样例、零值豁免与扫描范围),由 vitest.config.mts 的 scripts/**/*.spec.mjs 收集进 pnpm test。
    • 这条新单测立刻抓到我自己另一个实现缺陷:checkA4 的正则锚在行首,.a { padding: 13px; } 这种「整条规则写一行」会被整条漏掉——仓库 prettier 排版是每行一个声明,所以此前人工注入验证没暴露它。已改为按 { } ; 切块解析任意位置的声明。
  • 现状复核:pnpm fidelity 在真实仓库通过(215 个文件);规则单测 27/27 通过。

@babycoder-dev
babycoder-dev merged commit cf46551 into main Oct 7, 2026
3 checks passed
@babycoder-dev
babycoder-dev deleted the chore/agent-infra-p0 branch October 7, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant